package cn.orange.ch01_array;

/**
 * LC26.删除有序数组中的重复项
 */
public class LC26 {
    public int removeDuplicates(int[] nums) {
        int slow = 0;
        int fast = 1;
        while (fast < nums.length) {
            if (nums[fast] != nums[fast - 1]) {
                nums[++slow] = nums[fast];
            }
            fast++;
        }
        return slow + 1;
    }

    public static void main(String[] args) {
        LC26 alg = new LC26();
        System.out.println(alg.removeDuplicates(new int[]{1, 1, 2}));
        System.out.println(alg.removeDuplicates(new int[]{0, 0, 1, 1, 1, 2, 2, 3, 3, 4}));
    }
}
